package com.example.eduservice.controller;

import com.example.common.commonsutils.R;
import com.example.eduservice.entity.vo.EduSubjectVO;
import com.example.eduservice.service.EduSubjectService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Author:tjf
 * @Description:
 */
@RestController
@RequestMapping("/eduservice/subject")
@Tag(name = "课程分类控制器")
public class EduSubjectController {
    @Resource
    private EduSubjectService subjectService;
    @PostMapping(value = "/", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @Operation(description = "通过上传excel文件，新增课程分类")
    public R saveSubjects(@RequestPart MultipartFile file){
        return subjectService.saveSubjects(file);
    }
    @GetMapping("/")
    @Operation(description = "获取课程分类列表")
    public R getSubjectList(){
        List<EduSubjectVO> subjectList =  subjectService.getSubjectList();
        return R.ok().data("subjectList", subjectList);
    }
}
